<template>
  <el-card shadow="hover">
    <div class="header">
      <el-button type="primary" @click="handleAdd">发布新闻</el-button>
    </div>
    <el-table :data="newsList" style="width: 100%; margin-top: 20px">
      <el-table-column prop="title" label="标题"></el-table-column>
      <el-table-column prop="author" label="作者" width="120"></el-table-column>
      <el-table-column prop="date" label="日期" width="180"></el-table-column>
      <el-table-column label="操作" width="120">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.row)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</template>

<script>
export default {
  name: 'CampusNews',
  data() {
    return {
      newsList: [
        {
          title: '校园运动会圆满结束',
          author: '宣传部',
          date: '2023-10-15'
        },
        {
          title: '新学期开学典礼通知',
          author: '教务处',
          date: '2023-09-01'
        }
      ]
    }
  },
  methods: {
    handleAdd() {
      this.$message.info('发布新闻')
    },
    handleEdit(row) {
      this.$message.info(`编辑新闻 ${row.title}`)
    }
  }
}
</script>

<style scoped>
.header {
  margin-bottom: 20px;
}
</style>